package 剑指offer;

public class Offer46_JZ {
    public static int translateNum(int num) {
        String str = String.valueOf(num);
        int[] dp = new int[str.length()+1];
        dp[0] = 1; dp[1] = 1;
        for (int i=2; i<=str.length(); i++) {
            String temp = str.substring(i-2, i);
            if (temp.compareTo("10")>=0 && temp.compareTo("25")<=0) {
                dp[i] = dp[i-1] + dp[i-2];
            } else {
                dp[i] = dp[i-1];
            }
        }
        return dp[str.length()];
    }

    public static void main(String[] args) {
        System.out.println(translateNum(12258));
    }
}
